package com.actions.bluetoothbox2.util;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.actions.bluetoothbox2.R;

import java.util.List;

/**
 * Created by liuyong on 2017/12/21.
 */

public class slideLeftAdapter extends BaseAdapter {

    Context context;
    List<slideTitleInfo> list;

    public slideLeftAdapter(Context context, List<slideTitleInfo> list) {
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.item_slide_layout, parent, false);
        }
        ImageView img_ico = (ImageView) convertView.findViewById(R.id.img_ico);
        TextView tv_name = (TextView) convertView.findViewById(R.id.tv_name);
        img_ico.setImageResource(list.get(position).img_id);
        tv_name.setText(list.get(position).str);

        return convertView;
    }
}
